package DAO;

import Interfaces.IReservation_Dao;
import Models.Reservation;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Reservation_Dao implements IReservation_Dao {

    @Override
    public Reservation makeReservation(String Name, String LastName, String PhoneNumber, String SeatsNumber, String dateString) throws IllegalArgumentException {

        Connection conn = null;
        PreparedStatement pst = null;
        conn = javaconnect2.connectDB();
        try {
            String query = "INSERT INTO reservation (name , lastname , phonenumber , seatsnumber , date ) value (?,?,?,?,?)";
            pst = conn.prepareStatement(query);
            pst.setString(1, Name);
            pst.setString(2, LastName);
            pst.setString(3, PhoneNumber);
            pst.setString(4, SeatsNumber);
            pst.setString(5, dateString);
            pst.execute();
            
            pst.close();
            conn.close();
        } catch (SQLException e) {
            throw new IllegalArgumentException("Error in Reservation_Dao");
        }
        return null;

    }

}
